package com.tool.bean;

import com.tool.utils.PropertiesUtils;
import lombok.Value;

/**
 * 定义常量
 */

public class Constants {

    public static String AUTHOR_NAME;

    // 需要忽略的属性
    public static String IGNORE_BEAN_TOJSON_FILED;
    public static String IGNORE_BEAN_TOJSON_EXPRESSION;
    public static String IGNORE_BEAN_TOJSON_CLASS;

    // 日期序列化，反序列化
    public static String BEAN_DATE_FORMAT_EXPRESSION;
    public static String BEAN_DATE_FORMAT_CLASS;

    public static String BEAN_DATE_UNFORMAT_EXPRESSION;
    public static String BEAN_DATE_UNFORMAT_CLASS;

    public static Boolean IGNORE_TABLE_PREFIX;
    public static String SUFFIX_BEAN_QUERY;

    public static String PATH_BASE;
    public static String PATH_PO;
    public static String PATH_QUERY;
    public static String PATH_MAPPER;
    public static String PATH_SERVICE;
    public static String PATH_SERVICE_IMPL;
    public static String PATH_CONTROLLER;
    public static String COMMON_PATH_BASE;
    public static String COMMON_PATH_ENUMERATION;
    public static String COMMON_PATH_R;
    public static String COMMON_PATH_EXCEPTION;

    public static String PACKAGE_BASE;
    public static String PACKAGE_PO;
    public static String PACKAGE_QUERY;
    public static String PACKAGE_MAPPER;
    public static String PACKAGE_SERVICE;
    public static String PACKAGE_SERVICE_IMPL;
    public static String PACKAGE_CONTROLLER;
    public static String COMMON_PACKAGE_BASE;
    public static String COMMON_PACKAGE_ENUMERATION;
    public static String COMMON_PACKAGE_R;
    public static String COMMON_PACKAGE_EXCEPTION;


    static {
        // 需要忽略的属性
        IGNORE_BEAN_TOJSON_FILED = PropertiesUtils.getString("ignore.bean.tojson.filed");
        IGNORE_BEAN_TOJSON_EXPRESSION = "@JsonIgnore";
        IGNORE_BEAN_TOJSON_CLASS = "import com.fasterxml.jackson.annotation.JsonIgnore;";

        // 日期序列化，反序列化
        BEAN_DATE_FORMAT_EXPRESSION = PropertiesUtils.getString("bean.date.format.expression");
        BEAN_DATE_FORMAT_CLASS = "import com.fasterxml.jackson.annotation.JsonFormat;";

        BEAN_DATE_UNFORMAT_EXPRESSION = PropertiesUtils.getString("bean.date.unformat.expression");
        BEAN_DATE_UNFORMAT_CLASS = "import org.springframework.format.annotation.DateTimeFormat;";

        // 作者名称
        AUTHOR_NAME = PropertiesUtils.getString("author.name");

        // 是否忽略表前缀 参数bean后缀
        IGNORE_TABLE_PREFIX = Boolean.valueOf(PropertiesUtils.getString("ignore.table.prefix"));
        SUFFIX_BEAN_QUERY = PropertiesUtils.getString("suffix.bean.param");

        // 包名
        PACKAGE_BASE = PropertiesUtils.getString("package.base");
        PACKAGE_PO = PACKAGE_BASE + "." + PropertiesUtils.getString("package.po");
        PACKAGE_QUERY = PACKAGE_BASE + "." + PropertiesUtils.getString("package.query");
        PACKAGE_MAPPER = PACKAGE_BASE + "." + PropertiesUtils.getString("package.mapper");
        PACKAGE_SERVICE = PACKAGE_BASE + "." + PropertiesUtils.getString("package.service");
        PACKAGE_SERVICE_IMPL = PACKAGE_BASE + "." + PropertiesUtils.getString("package.service.impl");
        PACKAGE_CONTROLLER = PACKAGE_BASE + "." + PropertiesUtils.getString("package.controller");

        COMMON_PACKAGE_BASE = PropertiesUtils.getString("common.package.base");
        COMMON_PACKAGE_ENUMERATION = COMMON_PACKAGE_BASE + "." + PropertiesUtils.getString("common.package.enumeration");
        COMMON_PACKAGE_R = COMMON_PACKAGE_BASE + "." + PropertiesUtils.getString("common.package.R");
        COMMON_PACKAGE_EXCEPTION = COMMON_PACKAGE_BASE + "." + PropertiesUtils.getString("common.package.exception");

        // 路径
        PATH_BASE = PropertiesUtils.getString("path.base") ;
        PATH_PO = PATH_BASE + "/" + PACKAGE_PO.replace(".", "/");
        PATH_QUERY = PATH_BASE + "/" + PACKAGE_QUERY.replace(".", "/");
        PATH_MAPPER = PATH_BASE + "/" + PACKAGE_MAPPER.replace(".", "/");
        PATH_SERVICE = PATH_BASE + "/" + PACKAGE_SERVICE.replace(".", "/");
        PATH_SERVICE_IMPL = PATH_BASE + "/" + PACKAGE_SERVICE_IMPL.replace(".", "/");
        PATH_CONTROLLER = PATH_BASE + "/" + PACKAGE_CONTROLLER.replace(".", "/");

        COMMON_PATH_BASE = PropertiesUtils.getString("common.path.base") ;
        COMMON_PATH_ENUMERATION = COMMON_PATH_BASE + "/" + COMMON_PACKAGE_ENUMERATION.replace(".", "/");
        COMMON_PATH_R = COMMON_PATH_BASE + "/" + COMMON_PACKAGE_R.replace(".", "/");
        COMMON_PATH_EXCEPTION = COMMON_PATH_BASE + "/" + COMMON_PACKAGE_EXCEPTION.replace(".", "/");

    }

    public final static String[] SQL_DATE_TIME_TYPES = new String[] {"datetime", "timestamp"};
    public final static String[] SQL_DATE_TYPES = new String[] {"date"};
    public final static String[] SQL_DECIMAL_TYPES = new String[] {"decimal", "double", "float"};
    public final static String[] SQL_STRING_TYPES = new String[] {"char", "varchar", "text", "mediumtext", "longtext"};
    public final static String[] SQL_INTEGER_TYPES = new String[] {"int", "tinyint"};
    public final static String[] SQL_LONG_TYPES = new String[] {"bigint"};


    public static void main(String[] args) {
        System.out.println(COMMON_PATH_R);
        System.out.println(COMMON_PATH_ENUMERATION);
        System.out.println(COMMON_PACKAGE_ENUMERATION);
    }
}
